﻿using _14Net8AspNetCore_Authorization.Context;
using _14Net8AspNetCore_Authorization.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace _14Net8AspNetCore_Authorization.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PermissionController : ControllerBase
    {
        private readonly AuthorizationDbContext _DbContext;

        public PermissionController(AuthorizationDbContext dbContext)
        {
            _DbContext = dbContext;
        }


        /// <summary>
        /// 添加权限控制
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AddPermission(Permission permission)
        {
            _DbContext.permissions.Add(permission);
            _DbContext.SaveChanges();
            return Ok("添加成功");
        }

    }
}
